package com.io.model;

import io.netty.channel.ChannelHandlerContext;

import java.util.Date;
import java.util.concurrent.ConcurrentHashMap;

public class TerminalPrincipal {
    public int id;     //数据库中的Terminal的id
    public String vin;
    public String tid;
    public ChannelHandlerContext ctx;
    public Date registerDt;

    public short getNewTag() {
        return ++tag;
    }

    private short tag = 0; //当前自增tag

    public AsyncCallContextData popAccdObj(int tag){
        return asyncCallCtxData.remove(tag);
    }

    public AsyncCallContextData getAccdObj(int tag) {
        return asyncCallCtxData.getOrDefault(tag, null);
    }

    public void setAccdObj(int tag, AsyncCallContextData accd) {
        asyncCallCtxData.put(tag, accd);
    }

    //异步回调表,key为 (command<<16+tag)
    private ConcurrentHashMap<Integer, AsyncCallContextData> asyncCallCtxData = new ConcurrentHashMap<Integer, AsyncCallContextData>();

}
